//
//  YeeMineVC.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/2/27.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeMineVC.h"
#import "XRWeakSelfOrderSectionTableCell.h"
#import "YeeMineInfoHeaderTableViewCell.h"
#import "YeeLoginVC.h"//登录
#import "YeeSuggestVC.h"//意见反馈
#import "YeeCollectionVC.h"//收藏
#import "YeeSettingVC.h"   //设置
#import "YeeHelpVC.h"      //帮助说明
#import "YeeEditSelfVC.h"   //个人信息
#import "XRSelfAddressViewController.h"//地址管理
#import "ImageLodingView.h"
#import "YeeCollectionRootVC.h"
#import "YeePopCover.h" //遮罩

@interface YeeMineVC ()
{
    
    
}
@end

@implementation YeeMineVC

- (void)viewDidLoad
{
    [super viewDidLoad];
//    ImageLodingView  *loding=[[ImageLodingView alloc] initWithFrame:self.view.bounds];
//    [self.view addSubview:loding];
//    [loding startLoading];
    // Do any additional setup after loading the view.
}
-(void)addOwnViews
{
    self.hasTabbar=YES;
    [super addOwnViews];
}
-(void)addNavbarView
{
    UIBarButtonItem *setButton=[UIBarButtonItem itemWithBtnTitle:@"设置" target:self action:@selector(clickRightBlock:)];
    UIBarButtonItem *messageButton=[UIBarButtonItem itemWithBtnTitle:@"信息" target:self action:@selector(clickRightBlock:)];
    self.navigationItem.rightBarButtonItems=@[messageButton,setButton];
    
    
}
-(void)configOwnViews
{
    [super configOwnViews];
    [self.tableView registerClass:[XRWeakSelfOrderSectionTableCell class] forCellReuseIdentifier:NSStringFromClass([XRWeakSelfOrderSectionTableCell class])];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
    [self.tableView registerClass:[YeeMineInfoHeaderTableViewCell class] forCellReuseIdentifier:NSStringFromClass([YeeMineInfoHeaderTableViewCell class])];
    [self.view setBackgroundColor:xBackgroundColor];
    [self.tableView setBackgroundColor:xBackgroundColor];
    
}
-(void)clickRightBlock:(UIBarButtonItem *)clicksender
{
    
    [[YeePopCover shareManger]setBackgroundColor:kRandomFlatColor];
    //[[YeePopCover shareManger] removeCover];
    
//    
//    YeeSettingVC  *setVC=[YeeSettingVC new];
//    setVC.hidesBottomBarWhenPushed=YES;
//    [self.navigationController pushViewController:setVC animated:YES];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return section==0?1:(section==1?1:11);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [self configTableView:tableView ForRowAtIndexPath:indexPath];
}
-(UITableViewCell*)configTableView:(UITableView *)tableView ForRowAtIndexPath:(NSIndexPath*)indexPath
{
    switch (indexPath.section)
    {
    case 0:
        {
         YeeMineInfoHeaderTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YeeMineInfoHeaderTableViewCell class]) forIndexPath:indexPath];
            return cell;
        }
        break;
    case 1:
        {
        XRWeakSelfOrderSectionTableCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XRWeakSelfOrderSectionTableCell class]) forIndexPath:indexPath];
            return cell;
        }
        break;
    case 2:
        return [self configCommonCellTableView:tableView ForRowAtIndexPath:indexPath];
        break;
    default:
        break;
    }
   
    return nil;
}
#pragma mark 配置
-(UITableViewCell*)configCommonCellTableView:(UITableView *)tableView ForRowAtIndexPath:(NSIndexPath*)indexPath
{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    if (cell==nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([UITableViewCell class])];
    }
    cell.textLabel.textColor=kBlackColor;
    cell.textLabel.font=[UIFont Y_systemFontOfSize:IPhone4_5_6_6P(13, 13, 15, 15)];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    NSArray *titleArray=@[@"个人资料",@"我的收藏",@"我的优惠券",@"我的积分",@"地址管理",@"实名认证",@"账号安全",@"物业账号",@"联系客服",@"帮助说明",@"意见反馈"];
    cell.textLabel.text=titleArray[indexPath.row];
    return cell;
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] init];
    return view;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, 10)];
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return section==0?0.01:10.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return indexPath.section==0?60:46;
}
#pragma mark --点击单元格
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (indexPath.section==0)
    {
        
        YeeLoginVC  *loginVc=[[YeeLoginVC alloc] init];
        YeeNavigationController  *nav=[[YeeNavigationController alloc] initWithRootViewController:loginVc];
        [self presentViewController:nav animated:YES completion:^{
            
        }];
        
    }else if (indexPath.section==1)
    {
        
    }else
    {
       NSArray *VCArray=@[@"YeeEditSelfVC",@"YeeCollectionRootVC",@"YeeCollectionVC",@"YeeCollectionVC",@"XRSelfAddressViewController",@"YeeCollectionVC",@"YeeCollectionVC",@"YeeCollectionVC",@"YeeCollectionVC",@"YeeHelpVC",@"YeeSuggestVC"];
      [self mineViewPushtoSubViewsVC:VCArray[indexPath.row]];
    }
        
    
}
//跳转到不同的界面
-(void)mineViewPushtoSubViewsVC:(NSString *)VcString
{
    Class vcClass = NSClassFromString(VcString);
    UIViewController *vc = [[vcClass alloc] init];
    vc.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
